/**
 * app
 * created by xq on 2018/10/16
 */
import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import PropTypes from 'prop-types'
import * as ItemActions from '@actions'
import Header from './Header'
import Content from './Content'

class App extends React.Component {
  render() {
    console.log(this.props)
    return (
      <div>
        <Header searchText={this.props.searchText} changeSearchText={this.props.actions.changeSearchText} />
        <Content items={this.props.items} searchText={this.props.searchText} />
      </div>
    )
  }
}
App.propTypes = {
  searchText: PropTypes.string,
  items: PropTypes.array
}

export default connect(state => ({
  searchText: state.searchText,
  items: state.items
}), dispatch => ({
  actions: bindActionCreators(ItemActions, dispatch)
}))(App)